

import cv2 as cv
import matplotlib.pyplot as plt
from tools.showImg import ShowAndWait



#读取图像
def InputImg(path):

    img = cv.imread(path, 1)
    ShowAndWait('orgin_img', img)
    return img

# 图像预处理
def Preprocess(img,size):

    norm_img = cv.resize(img,tuple(size))
    plt.xticks(range(0, size[0], 100))
    plt.ylim(size[1], 0)
    plt.imshow(norm_img)
    plt.show()

    quzao_img = cv.fastNlMeansDenoisingColored(norm_img, None, 10, 3, 3, 3)
    ShowAndWait('quzao_img',quzao_img)
    gray = cv.cvtColor(quzao_img, cv.COLOR_BGR2GRAY)

    return gray
